#include "TextInputEvent.h"
#include "InputGameState.h"

TextInputEvent::TextInputEvent(char text)
    : text(text)
{
}

TextInputEvent::~TextInputEvent()
{
}

GameState* TextInputEvent::visitInputGameState(InputGameState* inputGameState) const
{
    if (isAlphaNumericKey() || isDotOrSpace())
    {
        return inputGameState->handleAlphaNumericKeys(text);
    }
    return NULL;
}

bool TextInputEvent::isAlphaNumericKey() const
{
    return (text >= 'a' && text <= 'z') || (text >= 'A' && text <= 'Z')
            || (text >= '0' && text <= '9');
}

bool TextInputEvent::isDotOrSpace() const
{
    return (text == ' ') || (text == '.');
}
